package com.mystore.common.paging;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class StylePage<T> extends Page<T> {
    private long start;
    private long end;
    private long next;

    public long getStart() {
        return start;
    }

    public void setStart(long start) {
        this.start = start;
    }

    public long getEnd() {
        return end;
    }

    public void setEnd(long end) {
        this.end = end;
    }

    public long getNext() {
        return next;
    }

    public void setNext(long next) {
        this.next = next;
    }

    public StylePage(IPage<T> page){
        super(page.getCurrent(),page.getSize(),page.getTotal());
        records=page.getRecords();
        orders=page.orders();
        maxLimit=page.maxLimit();
        setPages(page.getPages());
        //获取首页与当前页的最大值作为导航栏开始序号
        start = Math.max(1, current);
        //获取所有页与导航栏最大页数的最小值作为导航栏截止序号
        end = Math.min(getPages(), current + 4);
        //计算出下一页的current值
        next=Math.min(getPages(),current+1);
    }

    @Override
    public long getPages() {
        return super.getPages()==0?1:super.getPages();
    }
}
